import { XSTAGE_URL, createExtendApi } from '@/api/config';

import { postRequest, getRequest } from '/@/api/config/axios-fun';
import { ApiUtil } from "/@/utils/api.js";
import { XSTAGE_URL } from './url-config';

const _api = createExtendApi(XSTAGE_URL, 'upload', [
  { path: 'addFile', formDataFlag: true },
  { path: 'upload', formDataFlag: true },
]);

export const UploadAPI = {
  uploadFile(params, showMsgFlag = true, msg = '上传') {
    return new Promise((resolve) => {
      _api.addFile(params).then((resp) => {
        resolve({ ...ApiUtil.cleanHandler(resp, showMsgFlag, msg) });
      });
    });
  },
  uploadMoreFile(params, showMsgFlag = false, msg = '上传') {
    return new Promise((resolve) => {
      _api.upload(params).then((resp) => {
        resolve({ ...ApiUtil.cleanGet(resp, showMsgFlag, msg) });
      });
    });
  },

  uploadUrl: `${XSTAGE_URL}upload/addFile`,
  uploadMoreUrl: `${XSTAGE_URL}upload/upload`,
};
